/*    */ package com.qmsk.business.manage.function.controller;
/*    */ 
/*    */ import com.qmsk.business.manage.funcOper.dao.DutyFunOperDAO;
/*    */ import com.qmsk.business.manage.function.dao.DutyFunctionDAO;
/*    */ import com.utils.gson.in.ParserDataSetJson;
/*    */ import com.utils.gson.out.GsonEbRst;
/*    */ import com.utils.jdbc.connection.DbConnection;
/*    */ import com.utils.web.RequestUtils;
/*    */ import com.utils.web.ResponseUtils;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.transaction.annotation.Transactional;
/*    */ import org.springframework.web.bind.annotation.PathVariable;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"/dutyFun"})
/*    */ public class DutyFunctionController
/*    */ {
/* 29 */   private static final Logger logger = Logger.getLogger(DutyFunctionController.class);
/*    */ 
/*    */   @Autowired
/*    */   private DutyFunctionDAO dao;
/*    */ 
/*    */   @Autowired
/*    */   private DutyFunOperDAO dutyFunOperDao;
/*    */ 
/*    */   @RequestMapping(value={"find/shopId/{shopId}/root/{dutyId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public void getListOfRoot(HttpServletRequest request, HttpServletResponse response, @PathVariable("dutyId") String dutyId)
/*    */   {
/*    */     try
/*    */     {
/* 42 */       GsonEbRst gsonEbRst = this.dao.getGsonOfRoot(dutyId);
/* 43 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*    */     } catch (SQLException e) {
/* 45 */       logger.error(e);
/* 46 */       ResponseUtils.setErrorMsgResponse(
/* 47 */         RequestUtils.getFindDataErrorMessage(request), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"find/shopId/{shopId}/pId/{pId}/{dutyId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public void getListOfParentId(HttpServletRequest request, HttpServletResponse response, @PathVariable("pId") String pId, @PathVariable("dutyId") String dutyId)
/*    */   {
/*    */     try
/*    */     {
/* 57 */       GsonEbRst gsonEbRst = this.dao.getGsonOfParentId(pId, dutyId);
/* 58 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*    */     } catch (SQLException e) {
/* 60 */       logger.error(e);
/* 61 */       ResponseUtils.setErrorMsgResponse(
/* 62 */         RequestUtils.getFindDataErrorMessage(request), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"insert/shopId/{shopId}/all"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void insertAll(HttpServletRequest request, HttpServletResponse response)
/*    */   {
/*    */     try {
/* 71 */       String dutyId = request.getParameter("dutyId");
/* 72 */       this.dao.deleteOfDutyId(dutyId);
/* 73 */       this.dutyFunOperDao.deleteOfDutyId(dutyId);
/* 74 */       int nResult = this.dao.insertIntoDuty(dutyId);
/* 75 */       if (nResult > 0) {
/* 76 */         this.dutyFunOperDao.insertIntoDuty(dutyId);
/* 77 */         DbConnection.commit();
/*    */       } else {
/* 79 */         DbConnection.rollback();
/*    */       }
/* 81 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 82 */         RequestUtils.getSqlInsertDataErrorMessage(request), response);
/*    */     } catch (Exception e) {
/* 84 */       DbConnection.rollback();
/* 85 */       logger.error(e);
/* 86 */       ResponseUtils.setErrorMsgResponse(
/* 87 */         RequestUtils.getSqlInsertDataErrorMessage(request) + 
/* 88 */         ":" + e.getMessage(), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void insertList(HttpServletRequest request, HttpServletResponse response)
/*    */   {
/*    */     try {
/* 97 */       ParserDataSetJson p = new ParserDataSetJson(request
/* 98 */         .getParameter("data"));
/* 99 */       int nResult = this.dao.applyUpdates(p);
/* 100 */       if ((nResult > 0) || (!(p.isExistsRows()))) {
/* 101 */         ParserDataSetJson pDetail = 
/* 102 */           ParserDataSetJson.fromString(RequestUtils.getStringOfDetl(request));
/*    */ 
/* 115 */         nResult += this.dutyFunOperDao.applyUpdates(pDetail);
/* 116 */         DbConnection.commit();
/*    */       } else {
/* 118 */         DbConnection.rollback();
/*    */       }
/* 120 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 121 */         RequestUtils.getSqlInsertDataErrorMessage(request), response);
/*    */     } catch (Exception e) {
/* 123 */       DbConnection.rollback();
/* 124 */       logger.error(e);
/* 125 */       ResponseUtils.setErrorMsgResponse(
/* 126 */         RequestUtils.getSqlInsertDataErrorMessage(request) + 
/* 127 */         ":" + e.getMessage(), response);
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.manage.function.controller.DutyFunctionController
 * JD-Core Version:    0.5.3
 */